import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

import javax.swing.*;

public class PoolUtil {
    private static JedisPool pool;
    static {        //连接池配置
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        //最大连接数
        poolConfig.setMaxTotal(5);
        //最大空闲数
        poolConfig.setMaxIdle(1);

        String host="192.168.28.130";
        int port=6379;
        pool = new JedisPool(poolConfig,host,port);
    }
    public static Jedis getJedis() {

        Jedis jedis = pool.getResource();
        jedis.auth("123456");
        return jedis;
    }
}
